Implement exporting profile to single template string.#95
Implement exporting profile to single template string.#95RisaDev merged 5 commits intoAether-Tools:mainfrom
Conversation
useful for compressing multiple templates into just one uses IPCCharacterProfile similar to how PCP handling uses it to compress to one template
|
Built and tested locally. Doesn't change anything, simply adds workaround for this issue leveraging already existing methods. Also used windows clipboard for parity with template export to string, can change both together to IMGUI clipboard together. |
|
Hi, thank you for your contribution. If imgui's clipboard functionality doesn't have any known issues then it would be great if you could replace all of the current winforms-based implementation of clipboard import/export with that so we no longer need to reference windows-specific code. |
|
Having a look over at how Glamoure does this, OtterGui has this class to wrap the ImGui Clipboard functions, using Dalamud.Bindings.ImGui;
using OtterGui.Text.HelperObjects;
namespace OtterGui.Text;
public static partial class ImUtf8
{
/// <summary> Copy the given text to the clipboard. </summary>
/// <param name="text"> The text as a UTF8 string. HAS to be null-terminated. </param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void SetClipboardText(ReadOnlySpan<byte> text)
=> ImGui.SetClipboardText(text);
/// <param name="text"> The given text as a UTF16 string. </param>
/// <inheritdoc cref="SetClipboardText(ReadOnlySpan{byte})"/>
/// <exception cref="ImUtf8FormatException" />
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void SetClipboardText(ref Utf8StringHandler<TextStringHandlerBuffer> text)
=> SetClipboardText(text.Span());
/// <param name="text"> The given text as a formatted string. </param>
/// <inheritdoc cref="SetClipboardText(ReadOnlySpan{char})"/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void SetClipboardText(ReadOnlySpan<char> text)
=> SetClipboardText(text.Span<TextStringHandlerBuffer>());
/// <summary> Obtain the current text from the clipboard. </summary>
/// <returns> An owned, null-terminated span of UTF8 text. An empty (still null-terminated) span on failure. </returns>
public static TerminatedByteString GetClipboardTextUtf8()
{
var ptr = ImGui.GetClipboardTextU8();
return ptr.Length is 0
? TerminatedByteString.Empty
: ptr.CloneNullTerminated();
}
/// <inheritdoc cref="GetClipboardTextUtf8"/>
/// <returns> A string of the current clipboard text. An empty string on failure. </returns>
public static string GetClipboardText()
=> ImGui.GetClipboardText();
}Would you like me to use these instead? Currently, template export to clipboard uses ImGui dirrectly. |
|
Yea, copying the way glamourer/penumbra does things is always preferred. Just make sure you are not copying the code from OtterGui into C+, just update the submodule if it's too old and use those functions directly from there. |
|
just checked, the submodule is up to date with the repo, so will just update all to use the wrapper class. |
…instead of calling System.Windows.Forms / ImGui clipboard functions directly
…instead of calling System.Windows.Forms / ImGui clipboard functions directly, change tooltip on button to be more clear that it's about exporting a template
…ystem.Windows.Forms clipboard functions. fix popup window size on "You have unsaved changes in the current template", as the keep editing button was being cut off
…d crashes when using the file browser, and my visual studio is not showing whats used and not that well currently properly
Yea, let's do that.
You you feel like you can improve something and got some time for that - feel free to do that! |
I would advise against adjusting that without testing it on various resolutions because windows like this aren't being properly dynamically adjusted to the resolution right now and you might end up breaking it for a lot of people. |
|
Anyway the code seems to be more or less fine so I'll merge it and adjust a bit. If you'll be willing to test the window width change with multiple resolutions - feel free to make a new PR for it, for now I'll revert that change. Thanks for your contribution! |


useful for compressing multiple templates into just one
uses IPCCharacterProfile similar to how PCP handling uses it to compress to one templat
For issue #89